#ifndef TEXT_VIDEO_H
#define TEXT_VIDEO_H

#define TEXT_VIDEO_BASE         0xB8000

#define TEXT_VIDEO_WIDTH        80

#ifndef TEXT_VIDEO_HEIGHT
    #define TEXT_VIDEO_HEIGHT   25
#endif

#define TEXT_VIDEO_SIZE ((TEXT_VIDEO_WIDTH * TEXT_VIDEO_HEIGHT) * 2)

#define default_color   0x0A

#define va_list __builtin_va_list

#define va_rounded_size(type) \
(((sizeof(type) + sizeof(long) - 1) / sizeof(long)) * sizeof(long))

#define va_start(v,l)   __builtin_va_start(v,l)
#define va_end(v)       __builtin_va_end(v)
#define va_arg(v,l)     __builtin_va_arg(v,l)


#ifdef __DEBUG__
#define DEBUG(...)      if(1){ set_text_color(0x0F); printf(__VA_ARGS__); set_text_color(default_color); }
#else
#define DEBUG(...)      if(1){ }
#endif


#define WARNING(...)    if(1){ set_text_color(0x0C); printf(__VA_ARGS__); set_text_color(default_color); }

#include "stdint.h"

void clear_text_video(void);
void init_text_video(void);
void set_text_color(const uint8_t col);
void set_background_color(const uint8_t col);
void printf(const char * const buf, ...);
int vfprintf ( uint8_t * stream, const char * format, va_list ap );

#endif
